<template>
  <div>
    <el-container style="height: 100vh;" border="1px solid #eee">
      <el-header style="text-align: right; font-size: 12px">
        <el-dropdown @command="handleCommand">
          <i class="el-icon-setting" style="margin-right: 15px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="a">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <span>{{ user.username }}</span>
      </el-header>

      <el-container>
        <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
          <el-menu router default-active="/teacher">
            <el-submenu index="1">
              <template slot="title"><i class="el-icon-message"></i>教师管理</template>
              <el-menu-item-group>
                <el-menu-item index="/teacher">教师信息管理表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="2">
              <template slot="title"><i class="el-icon-message"></i>教室管理</template>
              <el-menu-item-group>
                <el-menu-item index="/room">教室信息管理表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>

        </el-aside>

        <el-main>
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style>
.el-header {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>

<script>
export default {
  data() {
    return {
      user: {},
    }
  },
  methods: {
    handleCommand(command) {
      if (command == 'a') {
        localStorage.removeItem("user");
        this.$router.push("/");
      }
    }
  },
  created() {
    this.user = JSON.parse(localStorage.getItem("user"));
  }
};
</script>